<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/Public/Admin/extend/favicon.ico" >
    <link rel="Shortcut Icon" href="/Public/Admin/extend/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/Public/Admin/extend/lib/html5shiv.js"></script>
    <script type="text/javascript" src="/Public/Admin/extend/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/Public/Admin/extend/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/Public/Admin/extend/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/Public/Admin/extend/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/Public/Admin/extend/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="/Public/Admin/extend/static/h-ui.admin/css/style.css" />
    <link href="/Public/Admin/extend/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
    <title>套餐修改</title>
    <link href="/Public/Admin/extend/lib/lightbox2/2.8.1/css/lightbox.css" rel="st ylesheet" type="text/css" >
    <style type="text/css">
              .filea {
            position: relative;
            display: inline-block;
            background: #D0EEFF;
            border: 1px solid #99D3F5;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #1E88C7;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
        }
        .filea input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }
        .filea:hover {
            background: #AADFFD;
            border-color: #78C3F3;
            color: #004974;
            text-decoration: none;
        }
          .select_style{
            box-sizing: border-box;
            border: solid 1px #ddd;
            width: 18%;
            height: 32px;
            font-size: 14px;
        }
    </style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 套餐管理 <span class="c-gray en">&gt;</span> 套餐修改
    </nav>
<div class="page-container" >

     <form class="form form-horizontal" id="form-agency">
     
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>套餐名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="<?php echo ($card['card_name']); ?>" id="card_name" name="card_name">
            </div>
        </div>
         <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>套餐分类：</label>
            <div class="formControls col-xs-8 col-sm-9">
               <select name="cat_id" class="select_style">
                 <option>请选择类别</option>
                  <?php if(is_array($category)): foreach($category as $key=>$cate): ?><option value="<?php echo ($cate['id']); ?>" <?php if($cate['id'] == $card['cat_id']): ?>selected<?php endif; ?>><?php echo ($cate['name']); ?></option><?php endforeach; endif; ?>
               </select>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">副标题：</label>
             <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="<?php echo ($card['title_name']); ?>" id="title_name" name="title_name" >
            </div>
        </div>
         <div class="row cl img">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上传封面图片：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div class="upimg_block" >
                        <div class="select_box" style="height:60px">
                            <div class="load_box" id="load_cover" ></div>
                            <div>
                                <div class="btn_box" style="float:left;margin-top:10px;" style="height:50px">
                                    <a href="javascript:;" class="filea">请选择（最多上传1张图片）
                                        <input type="file"  class="file" id="cover" name="cover">
                                    </a>
                                </div>
                                <div style="float:left;margin-left:10px;" id="show_cover_img">

                                </div>
                                <div style="float:left;margin-left:10px;" id="edit_cover_pic">
                                    <img style="height:70px" src="<?php echo ($card['card_cover']); ?>">
                                    <input type="hidden" name="cover_pic" value="<?php echo ($card['card_cover']); ?>">
                                </div>
                                <div style="clear:both;"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>市场价：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="number" style="width: 160px;" class="input-text" value="<?php echo ($card['market_price']); ?>" id="marketPrice" name="marketPrice" >
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>价格：</label>
             <div class="formControls col-xs-8 col-sm-9">
                <input type="number" style="width: 160px;" class="input-text" value="<?php echo ($card['shop_price']); ?>" id="shopPrice" name="shopPrice" >
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>使用时限：</label>
             <div class="formControls col-xs-8 col-sm-9">
                <input type="number" style="width: 160px;" class="input-text" value="<?php echo ($card['date_number']); ?>" id="date_number" name="date_number" >
                <select name='date_type' class="select_style">
                  <option value="">请选择类型</option>
                  <option value="Y" <?php if($card['date_type'] == 'Y'): ?>selected<?php endif; ?>>年</option>
                  <option value="M" <?php if($card['date_type'] == 'M'): ?>selected<?php endif; ?>>月</option>
                  <option value="D" <?php if($card['date_type'] == 'D'): ?>selected<?php endif; ?>>天</option>
                </select>
            </div>
        </div>
        
       <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">套餐内容：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <!--//script-->
                    <script id="editor" type="text/plain" style="width:100%;height:400px;"></script>
                </div>
       </div>
    
       
         <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>开放状态：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="radio" name="status" id='status' value="1" checked="checked">开放
                <input type="radio" name="status" id='status' value="0">暂不开放
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input name='id' type="hidden" id='id' value="<?php echo ($card['id']); ?>">
                <input class="btn btn-primary radius" type="submit" id='sub' value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
            </div>
        </div>
     
    </form>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/Public/Admin/extend/js/jquery-1.8.3.js"></script>

<script type="text/javascript" src="/Public/Admin/extend/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/Public/Admin/extend/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/lib/jquery.validation/1.14.0/messages_zh.js"></script>

<script src="/Public/Admin/extend/lib/exif.js?v=b26c6d5"></script>
<script src="/Public/Admin/extend/lib/lrz.js?v=c105d63"></script>
<!--upload-->

<script type="text/javascript" src="/Public/Admin/extend/lib/webuploader/0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="/Public/Admin/extend/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>

<script type="text/javascript">
    $(function(){
        var ue = UE.getEditor('editor', {
            toolbars: [
                [ 'source', 'undo', 'redo','bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc','searchreplace','scrawl','template','background','tolowercase','touppercase','autotypeset',],
                ['backcolor','insertorderedlist','insertunorderedlist','fullscreen','directionalityltr','directionalityrtl','customstyle','insertparagraphbeforetable','insertcode','fontfamily','fontsize','paragraph','pagebreak','insertframe','imagenone','imageleft','imageright','attachment','justifyleft','justifyright','justifycenter','justifyjustify','forecolor',],
                ['simpleupload','insertimage','inserttable','charts','spechars','edittable','edittd', 'link','lineheight','imagecenter','attachment','rowspacingtop','rowspacingbottom',],
            ],

            autoHeightEnabled: true,
            autoFloatEnabled: false
        });
        var info = '<?php echo htmlspecialchars_decode($card["content"]);?>';
        ue.ready(function(){
            ue.setContent(info);
        })
    });
    window.onload = function(){
        // //上传封面图片
        document.getElementById('cover').onchange = function(e){
            var theEvent = window.event || e;
            var img = theEvent.target.files[0];

            var img_box = $('#show_cover_img img').length;
            if(img_box>0){
                layer.msg("上传图片数目不可以超过1个", {icon: 2, time: 1000});
                return false;
            }

            //判断图片格式
            if(!(img.type.indexOf('image')==0 && img.type && /\.(?:gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(img.name)) ){
                layer.msg("图片只能是jpg,gif,png", {icon: 2, time: 1000});
                return ;
            }
            var reader = new FileReader();
            reader.readAsDataURL(img);

            reader.onload = function(e){ // reader onload start
                //alert("q");
                //压缩图片
                lrz(img, {
                    before: function() {
                        console.log('压缩开始');
                    },
                    fail: function(err) {
                        console.error(err);
                    },
                    always: function() {
                        console.log('压缩结束');
                    },
                    done: function (results) {

                        // 你需要的数据都在这里，可以以字符串的形式传送base64给服务端转存为图片。
                        //demo_report('客户端预压的图片', results.base64, results.base64.length * 0.8);
                        // ajax 上传图片
                        $('#load_cover').html('正在上传照片...');

                        $.post("<?php echo U('Admin/Admin/uploadTempPic');?>", { Upload_img: results.base64},function(ret){
                            $('#load_cover').hide();
                            if(ret.status != undefined) {
                                if (!ret.status) {
                                    layer.msg(ret.info, {icon: 2, time: 1000});
                                    return;
                                }
                            }
                            if(ret.Upload_img!=''){
                                layer.msg("上传成功", {icon: 6, time: 1000});
                                img_html='<img style="height:70px" src="' + ret.Upload_img + '">';
                                img_html+='<input type="hidden" name="new_cover_pic" value="'+ret.Upload_img+'">';
                                $("#edit_cover_pic").html("");
                                $('#show_cover_img').append(img_html);

                                $("#cover").reset();
                            }else{
                                layer.msg("上传失败", {icon: 2, time: 1000});
                            }
                        },'json');
                    } //done end
                });
            } // reader onload end
        }
    };

            //表单验证
        $("#form-agency").validate({
            rules: {
//                goods_sn: {
//                    required: true,
//                },
            },
            onkeyup: false,
            focusCleanup: true,
            success: "valid",
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    type: 'post',
                    url: "<?php echo U('Admin/Card/cardEdit');?>",
                    success: function (data) {
                        if (data.status) {
                            layer.msg(data.info, {icon: 6, time: 1000});
                            setTimeout((function () {
                               window.location.href = "<?php echo U('Admin/Card/cardList',array('p'=>$p));?>";
                            }), 1500);
                        } else {
                            layer.msg(data.info, {icon: 2, time: 1000});
                        }
                    },
                    error: function (XmlHttpRequest, textStatus, errorThrown) {
                        layer.msg('error!', {icon: 5, time: 1000});
                    }
                });
            }
        });

</script>
</body>
</html>